/**
 * @description 处理用户登录路由
 */
const express = require("express");

const router = express.Router();

const userHandler = require("../router-handler/user");

// 导入验证数据的中间件配合@hapi/joi 使用
const expressJoi = require("@escook/express-joi");

// 导入需要验证的验证规则对象
const { reg_login_schema, reg_reguser_schema } = require("../schema/user");

// 获取验证码
router.get("/captcha", userHandler.captcha);

// 注册新用户，局部注册中间件去校验，路由处理函数抽离
router.post("/reguser", expressJoi(reg_reguser_schema), userHandler.reguser);

// 登录
router.post("/login", expressJoi(reg_login_schema), userHandler.login);

module.exports = router;
